package com.lris.controller;

import com.lris.constant.MessageConstant;
import com.lris.dto.AddUserFriendDto;
import com.lris.result.PageResult;
import com.lris.result.Result;
import com.lris.service.FriendRelationsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
@Slf4j
@Tag(name = "好友关系模块")
@RequestMapping("/lris/Friend")
public class FriendRelationsController {

    /**
     * 好有
     */
    private final FriendRelationsService friendRelationsService;

    @PostMapping("/addFriend")
    @Operation(summary = "添加好友")
    public Result AddUserFriend(@RequestBody AddUserFriendDto addUserFriendDto) {
        return friendRelationsService.addUserFriend(addUserFriendDto);
    }

    @GetMapping("/allFriend")
    @Operation(summary = "获取用户好友列表")
    public Result<PageResult> findFriendAllById( Integer page, Integer pageSize ,Long userid) {

        log.info("page:"+page+"pagesize"+pageSize+"用户id"+userid);
        if(null==userid){
            return Result.error("id"+ MessageConstant.FILED_NOT_NULL);
        }
        PageResult pageResult=friendRelationsService.findFriendAllById(page,pageSize,userid);
        return Result.success(pageResult);
    }
}
